from django.db import models

class ItemTemplate(models.Model):
	class Meta:
		db_table = 'mangos.item_template'
		managed = False
		
	entry = models.PositiveIntegerField(primary_key=True)
	klass = models.PositiveSmallIntegerField(default=0, db_column='class')
	subclass = models.PositiveSmallIntegerField(default=0)
	unk0 = models.IntegerField(default=-1)
	name = models.CharField(max_length=255, default='')
	displayid = models.PositiveIntegerField(default=0)
	Quality = models.PositiveSmallIntegerField(default=0)
	Flags = models.PositiveIntegerField(default=0)
	BuyCount = models.PositiveSmallIntegerField(default=1)
	BuyPrice = models.PositiveIntegerField(default=0)
	SellPrice = models.PositiveIntegerField(default=0)
	InventoryType = models.PositiveSmallIntegerField(default=0)
	AllowableClass = models.IntegerField(default=-1)
	AllowableRace = models.IntegerField(default=-1)
	ItemLevel = models.PositiveSmallIntegerField(default=0)
	RequiredLevel = models.PositiveSmallIntegerField(default=0)
	RequiredSkill = models.PositiveSmallIntegerField(default=0)
	RequiredSkillRank = models.PositiveSmallIntegerField(default=0)
	requiredspell = models.PositiveIntegerField(default=0)
	requiredhonorrank = models.PositiveIntegerField(default=0)
	RequiredCityRank = models.PositiveIntegerField(default=0)
	RequiredReputationFaction = models.PositiveSmallIntegerField(default=0)
	RequiredReputationRank = models.PositiveSmallIntegerField(default=0)
	maxcount = models.PositiveSmallIntegerField(default=0)
	stackable = models.PositiveSmallIntegerField(default=1)
	ContainerSlots = models.PositiveSmallIntegerField(default=0)
	stat_type1 = models.PositiveSmallIntegerField(default=0)
	stat_value1 = models.SmallIntegerField(default=0)
	stat_type2 = models.PositiveSmallIntegerField(default=0)
	stat_value2 = models.SmallIntegerField(default=0)
	stat_type3 = models.PositiveSmallIntegerField(default=0)
	stat_value3 = models.SmallIntegerField(default=0)
	stat_type4 = models.PositiveSmallIntegerField(default=0)
	stat_value4 = models.SmallIntegerField(default=0)
	stat_type5 = models.PositiveSmallIntegerField(default=0)
	stat_value5 = models.SmallIntegerField(default=0)
	stat_type6 = models.PositiveSmallIntegerField(default=0)
	stat_value6 = models.SmallIntegerField(default=0)
	stat_type7 = models.PositiveSmallIntegerField(default=0)
	stat_value7 = models.SmallIntegerField(default=0)
	stat_type8 = models.PositiveSmallIntegerField(default=0)
	stat_value8 = models.SmallIntegerField(default=0)
	stat_type9 = models.PositiveSmallIntegerField(default=0)
	stat_value9 = models.SmallIntegerField(default=0)
	stat_type10 = models.PositiveSmallIntegerField(default=0)
	stat_value10 = models.SmallIntegerField(default=0)
	dmg_min1 = models.FloatField(default=0)
	dmg_max1 = models.FloatField(default=0)
	dmg_type1 = models.PositiveSmallIntegerField(default=0)
	dmg_min2 = models.FloatField(default=0)
	dmg_max2 = models.FloatField(default=0)
	dmg_type2 = models.PositiveSmallIntegerField(default=0)
	dmg_min3 = models.FloatField(default=0)
	dmg_max3 = models.FloatField(default=0)
	dmg_type3 = models.PositiveSmallIntegerField(default=0)
	dmg_min4 = models.FloatField(default=0)
	dmg_max4 = models.FloatField(default=0)
	dmg_type4 = models.PositiveSmallIntegerField(default=0)
	dmg_min5 = models.FloatField(default=0)
	dmg_max5 = models.FloatField(default=0)
	dmg_type5 = models.PositiveSmallIntegerField(default=0)
	armor = models.PositiveSmallIntegerField(default=0)
	holy_res = models.PositiveSmallIntegerField(default=0)
	fire_res = models.PositiveSmallIntegerField(default=0)
	nature_res = models.PositiveSmallIntegerField(default=0)
	frost_res = models.PositiveSmallIntegerField(default=0)
	shadow_res = models.PositiveSmallIntegerField(default=0)
	arcane_res = models.PositiveSmallIntegerField(default=0)
	delay = models.PositiveIntegerField(default=1000)
	ammo_type = models.PositiveSmallIntegerField(default=0)
	RangedModRange = models.FloatField(default=0)
	spellid_1 = models.PositiveSmallIntegerField(default=0)
	spelltrigger_1 = models.PositiveSmallIntegerField(default=0)
	spellcharges_1 = models.SmallIntegerField(default=0)
	spellppmRate_1 = models.FloatField(default=0)
	spellcooldown_1 = models.IntegerField(default=-1)
	spellcategory_1 = models.PositiveSmallIntegerField(default=0)
	spellcategorycooldown_1 = models.IntegerField(default=-1)
	spellid_2 = models.PositiveSmallIntegerField(default=0)
	spelltrigger_2 = models.PositiveSmallIntegerField(default=0)
	spellcharges_2 = models.SmallIntegerField(default=0)
	spellppmRate_2 = models.FloatField(default=0)
	spellcooldown_2 = models.IntegerField(default=-1)
	spellcategory_2 = models.PositiveSmallIntegerField(default=0)
	spellcategorycooldown_2 = models.IntegerField(default=-1)
	spellid_3 = models.PositiveSmallIntegerField(default=0)
	spelltrigger_3 = models.PositiveSmallIntegerField(default=0)
	spellcharges_3 = models.SmallIntegerField(default=0)
	spellppmRate_3 = models.FloatField(default=0)
	spellcooldown_3 = models.IntegerField(default=-1)
	spellcategory_3 = models.PositiveSmallIntegerField(default=0)
	spellcategorycooldown_3 = models.IntegerField(default=-1)
	spellid_4 = models.PositiveSmallIntegerField(default=0)
	spelltrigger_4 = models.PositiveSmallIntegerField(default=0)
	spellcharges_4 = models.SmallIntegerField(default=0)
	spellppmRate_4 = models.FloatField(default=0)
	spellcooldown_4 = models.IntegerField(default=-1)
	spellcategory_4 = models.PositiveSmallIntegerField(default=0)
	spellcategorycooldown_4 = models.IntegerField(default=-1)
	spellid_5 = models.PositiveSmallIntegerField(default=0)
	spelltrigger_5 = models.PositiveSmallIntegerField(default=0)
	spellcharges_5 = models.SmallIntegerField(default=0)
	spellppmRate_5 = models.FloatField(default=0)
	spellcooldown_5 = models.IntegerField(default=-1)
	spellcategory_5 = models.PositiveSmallIntegerField(default=0)
	spellcategorycooldown_5 = models.IntegerField(default=-1)
	bonding = models.PositiveSmallIntegerField(default=0)
	description = models.CharField(max_length=255, default='')
	PageText = models.PositiveSmallIntegerField(default=0)
	LanguageID = models.PositiveSmallIntegerField(default=0)
	PageMaterial = models.PositiveSmallIntegerField(default=0)
	startquest = models.PositiveIntegerField(default=0)
	lockid = models.PositiveSmallIntegerField(default=0)
	Material = models.SmallIntegerField(default=0)
	sheath = models.PositiveSmallIntegerField(default=0)
	RandomProperty = models.PositiveIntegerField(default=0)
	RandomSuffix = models.PositiveIntegerField(default=0)
	block = models.PositiveSmallIntegerField(default=0)
	itemset = models.PositiveSmallIntegerField(default=0)
	MaxDurability = models.PositiveSmallIntegerField(default=0)
	area = models.PositiveSmallIntegerField(default=0)
	Map = models.SmallIntegerField(default=0)
	BagFamily = models.SmallIntegerField(default=0)
	TotemCategory = models.SmallIntegerField(default=0)
	socketColor_1 = models.SmallIntegerField(default=0)
	socketContent_1 = models.SmallIntegerField(default=0)
	socketColor_2 = models.SmallIntegerField(default=0)
	socketContent_2 = models.SmallIntegerField(default=0)
	socketColor_3 = models.SmallIntegerField(default=0)
	socketContent_3 = models.SmallIntegerField(default=0)
	socketBonus = models.IntegerField(default=0)
	GemProperties = models.IntegerField(default=0)
	RequiredDisenchantSkill = models.SmallIntegerField(default=-1)
	ArmorDamageModifier = models.FloatField(default=0)
	ScriptName = models.CharField(max_length=64,default='')
	DisenchantID = models.PositiveIntegerField(default=0) # FIXME: reference
	FoodType = models.PositiveSmallIntegerField(default=0)
	minMoneyLoot = models.PositiveIntegerField(default=0)
	maxMoneyLoot = models.PositiveIntegerField(default=0)
	Duration = models.IntegerField(default='0') #'Duration in seconds. Negative value means realtime, postive value ingame time',


class ReferenceLootTemplate(models.Model):
	
	class Meta:
		db_table = 'mangos.reference_loot_template'
		managed = False
	
	entry = models.PositiveIntegerField(primary_key=True)
	item = models.ForeignKey(ItemTemplate, default=0)
	chance = models.FloatField(default=100)
	groupid = models.PositiveSmallIntegerField(default=0)
	mincountOrRef = models.IntegerField(default=1)
	maxcount = models.PositiveIntegerField(default=1)
	lootcondition = models.PositiveIntegerField(default=0)
	condition_value1 = models.PositiveIntegerField(default=0)
	condition_value2 = models.PositiveIntegerField(default=0)


class CreatureLootTemplate(models.Model):
		
	class Meta:
		db_table = 'mangos.creature_loot_template'
		managed = False
	
	entry = models.PositiveIntegerField(primary_key=True)
	item = models.ForeignKey(ItemTemplate, default=0)
	chance = models.FloatField(default=100, db_column='ChanceOrQuestChance')
	groupid = models.PositiveSmallIntegerField(default=0)
	mincountOrRef = models.IntegerField(default=1)
	maxcount = models.PositiveIntegerField(default=1)
	lootcondition = models.PositiveIntegerField(default=0)
	condition_value1 = models.PositiveIntegerField(default=0)
	condition_value2 = models.PositiveIntegerField(default=0)


class CreatureTemplate(models.Model):
	
	class Meta:
		db_table = 'mangos.creature_template'
		managed = False
	
	entry = models.PositiveIntegerField(primary_key=True)
	heroic_entry = models.PositiveIntegerField(default=0) # FIXME: reference
	modelid_A = models.PositiveIntegerField(default=0)
	modelid_A2 = models.PositiveIntegerField(default=0)
	modelid_H = models.PositiveIntegerField(default=0)
	modelid_H2 = models.PositiveIntegerField(default=0)
	name = models.CharField(max_length=100, default='0')
	subname = models.CharField(max_length=100, null=True)
	IconName = models.CharField(max_length=100, null=True)
	minlevel = models.PositiveSmallIntegerField(default=1)
	maxlevel = models.PositiveSmallIntegerField(default=1)
	minhealth = models.PositiveIntegerField(default=0)
	maxhealth = models.PositiveIntegerField(default=0)
	minmana = models.PositiveIntegerField(default=0)
	maxmana = models.PositiveIntegerField(default=0)
	armor = models.PositiveSmallIntegerField(default=0)
	faction_A = models.PositiveSmallIntegerField(default=0)
	faction_H = models.PositiveSmallIntegerField(default=0)
	npcflag = models.PositiveIntegerField(default=0)
	speed = models.FloatField(default=1)
	scale = models.FloatField(default=1)
	rank = models.PositiveSmallIntegerField(default=0)
	mindmg = models.FloatField(default=0)
	maxdmg = models.FloatField(default=0)
	dmgschool = models.SmallIntegerField(default=0)
	attackpower = models.PositiveIntegerField(default=0)
	baseattacktime = models.PositiveIntegerField(default=0)
	rangeattacktime = models.PositiveIntegerField(default=0)
	unit_flags = models.PositiveIntegerField(default=0)
	dynamicflags = models.PositiveIntegerField(default=0)
	family = models.SmallIntegerField(default=0)
	trainer_type = models.SmallIntegerField(default=0)
	trainer_spell = models.PositiveIntegerField(default=0) # FIXME: reference
	klass = models.PositiveSmallIntegerField(default=0, db_column='class')
	race = models.PositiveSmallIntegerField(default=0)
	minrangedmg = models.FloatField(default=0)
	maxrangedmg = models.FloatField(default=0)
	rangedattackpower = models.PositiveSmallIntegerField(default=0)
	type = models.PositiveSmallIntegerField(default=0)
	type_flags = models.PositiveIntegerField(default=0)
	lootid = models.ForeignKey(CreatureLootTemplate)
	pickpocketloot = models.PositiveIntegerField(default=0) # FIXME: reference!
	skinloot = models.PositiveIntegerField(default=0) # FIXME : reference!
	resistance1 = models.SmallIntegerField(default=0)
	resistance2 = models.SmallIntegerField(default=0)
	resistance3 = models.SmallIntegerField(default=0)
	resistance4 = models.SmallIntegerField(default=0)
	resistance5 = models.SmallIntegerField(default=0)
	resistance6 = models.SmallIntegerField(default=0)
	spell1 = models.PositiveIntegerField(default=0) # FIXME: reference
	spell2 = models.PositiveIntegerField(default=0) # FIXME: reference
	spell3 = models.PositiveIntegerField(default=0) # FIXME: reference
	spell4 = models.PositiveIntegerField(default=0) # FIXME: reference
	PetSpellDataId = models.PositiveIntegerField(default=0) #
	mingold = models.PositiveIntegerField(default=0)
	maxgold = models.PositiveIntegerField(default=0)
	AIName = models.CharField(max_length=64, default='')
	MovementType = models.PositiveSmallIntegerField(default=0)
	InhabitType = models.PositiveSmallIntegerField(default=3)
	RacialLeader = models.PositiveSmallIntegerField(default=0)
	RegenHealth = models.PositiveSmallIntegerField(default=1)
	equipment_id = models.PositiveIntegerField(default=0) # FIXME: reference
	mechanic_immune_mask = models.PositiveIntegerField(default=0)
	flags_extra = models.PositiveIntegerField(default=0)
	ScriptName = models.CharField(max_length=64,default='')
